<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('培训师评价任务列表')" />
	<th:block th:include="include :: list-css" />
	<style type="text/css">
		.layui-tab-title li{font-weight:600}
	</style>
</head>
<body>
<div class="main-content">
	<div class="content-right">
   		<div class="search-top">
			<span>查询条件</span>
			<a href="javascript:;" layadmin-event="flexible" class="menuBtn">
				<i class="layui-icon layui-icon-spread-left" id="LAY_app_flexible" style="color: #fff;"></i>
			</a>
		</div>
        <div class="panel layout-expand layui-expand-east">
            <div class="panel-header">
                <div class="panel-tool" style="text-align: center; width: 26px;height: 30px;line-height: 30px;">
                    <a href="javascript:;" layadmin-event="flexible" class="menuBtn">
                        <i class="layui-icon layui-icon-shrink-right" id="LAY_app_flexible" style="color: #fff;"></i>
                    </a>
                </div>
            </div>
            <div class="panel-body panel-title" style="text-align: center; width: 26px;">查<br>询<br>条<br>件</div>
        </div>
       	<form class="layui-form">
		    <th:block th:include="listinclude :: searchRight('page')" />
		</form>
	</div>
   	<div class="mid-content">
		<div class="layui-tab" lay-filter="dhtab">
		  <ul class="layui-tab-title">
		    <li class="layui-this">待评<p class="layui-badge" id="badge1" style="border-radius: 10px;">0</p></li>
		    <li>草稿<p class="layui-badge" id="badge2" style="border-radius: 10px;">0</p></li>
		    <li>已评</li>
		    <li>全部</li>
		  </ul>
		  <div class="layui-tab-content" style="border: 1px solid #099;padding: 10px 15px;">
		    <table class="layui-hide" id="dhtable" lay-filter="ftable"></table>
		  </div>
		</div>
   	</div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: businessJS" />
<th:block th:include="include :: searchJS" />
<!-- 操作区 -->
<script type="text/html" id="barDh">
	<a class="layui-btn layui-btn-xs dhicon dh-search layui-btn-warm" onclick="read('{{d.guid}}','{{d.cUser}}','{{d.cUserName}}','{{d.LAY_TABLE_INDEX}}');">&nbsp;详情</a>	   
</script>
<script th:inline="javascript">
	/*<![CDATA[*/
	var prefix = ctx + [[${prefix}]],
		moduleTable=[[${moduleTable}]],
		gridColumns=[[${gridColumns}]];
	/*]]>*/
</script>
<script type="text/javascript">
var $,layer,form,element,table,laydate,wherestr={};
layui.use(['table','form','layer','jquery','element','laydate'], function () {
    $ = layui.$, layer = layui.layer, form = layui.form, table = layui.table, element = layui.element,laydate =layui.laydate;
    serachRender();//查询条件初始渲染集合
    refreshBadge();//显示待评、草稿数量
    $.tablelist.init({//默认待评
        elem: '#dhtable'
        ,url: prefix + '/pjlist'
    	,even:true
        ,totalRow: true
        ,where:{'vPjZt':'待评'}
        ,cols:[gridColumns.gridBody
	 	]
		,height:'full-125'
    });
	//监听排序事件 
    table.on('sort(ftable)', function(obj){
    	$.tablelist.sort('dhtable',obj);
    });
	//监听Tab页
 	element.on('tab(dhtab)', function(data){
 		switch(data.index){
 			case 0:
 				var wherestr={'vPjZt':'待评'};
 				break;
 			case 1:
 				var wherestr={'vPjZt':'草稿'};
 				break;
 			case 2:
 				var wherestr={'vPjZt':'已评'};
 				break;
			default:
				var wherestr={'vPjZt':''};
 				break;	
 		}
 		table.reload('dhtable', {page: {curr: 1},where:wherestr});
	});
});
function read(guid,cid,cname,tindex){//查看详情页
	var dcache=table.cache.dhtable[tindex],btn;
	var url=prefix+'/pj?pageType=edit&guid='+guid;
	if($.inArray(dcache['vPjZt'],['待评','草稿'])>-1)btn=['保存','提交','关闭'];else btn=['关闭'];
	layer.config({extend: 'myskin/style.css'});//加载扩展样式
	layer.open({
		type: 2,
		skin:'reset-class',
		area: [($(window).width() - 400)+'px', ($(window).height() - 200)+'px'],
		fix: false,//不固定
		offset: '10%',//距离顶部
		maxmin: true,//最大最小化
		shade: 0.3,//遮罩
		title: '培训师评价表-'+cname+'('+cid+')',
		content: url,
		btn: btn,
		shadeClose: true,// 弹层外区域关闭
		success: function(layero, index){
		},
		btn1: function(index, layero){
			if(btn.toString()==['关闭'].toString()){
				layer.close(index);
			}else{
				if(window["layui-layer-iframe" + index].btn1()){
					setTimeout(function(){
			        	layer.close(index);
			        	table.reload('dhtable');
			        	refreshBadge();//显示待评、草稿数量
	                }, 1000);
				}
			}
		},
		btn2:function(index,layero){
			if(window["layui-layer-iframe" + index].btn2()){
				setTimeout(function(){
		        	layer.close(index);
		        	table.reload('dhtable');
		        	refreshBadge();//显示待评、草稿数量
                }, 1000);
			}
			return false;//开启该代码可禁止点击该按钮关闭（true为开启关闭）
		}
	});
}
function refreshBadge(){//显示待评、草稿数量
	$.get(prefix + '/pjlist',function(res){
    	if(res.code==0){
        	var badge1=0,badge2=0;
        	$.each(res.data,function(i,v){
        		if(v.vPjZt=='待评')badge1+=1;
        		if(v.vPjZt=='草稿')badge2+=1;
        	})
        	$('#badge1').text(badge1);
        	$('#badge2').text(badge2);
        }
   	});
}
</script>
</body>
</html>